#ifndef FORMSLAVESTATE_H
#define FORMSLAVESTATE_H

#include <QWidget>
#include <QTimer>
#include <QVector>

#include "udpworker.h"
#include "dcsdb/dcsdboperator.h"

namespace Ui
{
    class FormSlaveState;

    class SlaveOnlineState;
}

/**
 * @brief The SlaveOnlineState class
 * 分控在线状态
 */
class SlaveOnlineState
{
public:
    SlaveOnlineState(unsigned int i, unsigned int s = 0)
    {
        mId = i;
        mState = s;
    }

    SlaveOnlineState() : mId(0), mState(0) {}

    unsigned int id()
    {
        return mId;
    }

    void setId(unsigned int i)
    {
        mId = i;
    }

    unsigned int state()
    {
        return mState;
    }

    void setState(unsigned s)
    {
        mState = s;
    }

private:
    unsigned int mId;        /*分控ID*/
    unsigned int mState;     /*分控在线状态0:离线，1：在线*/
};

class FormSlaveState : public QWidget
{
Q_OBJECT

public:
    explicit FormSlaveState(QWidget *parent = 0);

    ~FormSlaveState();

private slots:

    void on_pushButtonSlaveStatReturn_clicked();

    void on_cmdSendTimerout();

    void on_dataRecved(QByteArray &data);

private:
    Ui::FormSlaveState *ui;
    DCSDbOperator *mDbopt;
    quint8 mslaveNum;
    QTimer cmdSendTimer;
    UdpWorker *mUdp;
    QVector<SlaveOnlineState> mOnline;
};

#endif // FORMSLAVESTATE_H
